import express from 'express';
import { submitTask, getTaskList, getTaskResult } from '../controllers/scoringController.js';
import { authenticateToken } from '../middleware/auth.js';
import { uploadMedicalImage } from '../middleware/upload_simple.js';

const router = express.Router();

// 提交评分任务 - 需要认证和文件上传
router.post('/submit', authenticateToken, (req, res, next) => {
  console.log('🔍 Scoring路由被调用');
  console.log('🔍 请求头:', req.headers['content-type']);
  console.log('🔍 请求体字段:', Object.keys(req.body || {}));
  uploadMedicalImage(req, res, next);
}, submitTask);

// 获取评分任务列表 - 需要认证
router.post('/list', authenticateToken, getTaskList);

// 获取单个评分结果 - 需要认证
router.post('/result', authenticateToken, getTaskResult);
router.get('/result/:taskId', authenticateToken, getTaskResult);

export default router;